import React from 'react';
import {Text, View} from "@tarojs/components";
import CommentRate from "@/components/Comment/Rate";

import './index.scss'



//评分信息
const CommentScoreInfo = ({shopScore=0,data=[]}) =>{
  let dliverySatisfaction='-'
  let list=[]
  for(let item of data){
    if(item.scoreTypeId==4){
      dliverySatisfaction=item.score
    }else{
      list.push(item)
    }
  }
  return (
    <View className="commentScoreInfo">
      <View className="score flexMiddle">
        <View className="num">{parseFloat(shopScore||0).toFixed(1)}</View>
        <View className="text">商家评分</View>
      </View>
      <View className="center flexMiddle">
        {list.slice(0,4).map(item=>{
          return (
            <View className="centerRow" key={item.scoreTypeId}>
              <Text>{item.name}</Text><CommentRate class="rate" value={item.score} /><Text>{parseFloat(item.score).toFixed(1)}</Text>
            </View>
          )
        })}
      </View>
      <View className="score flexMiddle">
        <View className="num">{parseInt(parseFloat(dliverySatisfaction))}%</View>
        <View className="text">配送满意度</View>
      </View>
    </View>
  )
}
export default CommentScoreInfo
